package com.ytplayer.screens 
{
	import com.ytplayer.assets.SongItem;
	import com.ytplayer.assets.SongList;
	import com.ytplayer.player.YoutubeVideoPlayer;
	import com.ytplayer.remote.services.LibraryService;
	import com.ytplayer.remote.Video;
	import com.ytplayer.screen.Screen;
	
	/**
	 * ...
	 * @author Jakub Wagner, FEL
	 */
	public class PlayerScreen extends Screen 
	{
		private var youtubePlayer:YoutubeVideoPlayer;
		private var songsList:SongList = new SongList();
				
		public function PlayerScreen() 
		{		
			youtubePlayer = YoutubeVideoPlayer.getInstance();
			addChild(youtubePlayer);
			addChild(songsList);
			
			var ls:LibraryService = new LibraryService();
			ls.getAllVideos(0, 5, onGetAllVideos);			
		}
		
		private function onGetAllVideos(o:Array):void 
		{
			songsList.updateList(o);
			
			youtubePlayer.loadVideoById(o[0].url);
		}		
		
		override public function setSize(__width:Number, __height:Number, applyMargins:Boolean = true):void 
		{
			youtubePlayer.setSize(__width - 200, __height); 
			
			songsList.x = __width - 200;
			
			super.setSize(__width, __height, applyMargins);
		}
		
		
	}

}